﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;
using System.Text;
using System.Configuration;
using System.Web.Security;

namespace eStreamChat
{
    public partial class ChangePassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            TxtUsername.Text = Membership.GetUser().UserName;
            TxtEmail.Text = Membership.GetUser().Email;

        }

        protected void ChangePasswordUser_ChangedPassword(object sender, EventArgs e)
        {
            string id = User.Identity.Name;
            string secretKey = "abc123";
            string timestamp = DateTime.Now.ToString("yyMMddhhmmss");
            SHA1Managed sha1 = new SHA1Managed();
            byte[] paramBytes = Encoding.UTF8.GetBytes(id + timestamp + secretKey);
            byte[] hashBytes = sha1.ComputeHash(paramBytes);
            string hash = BitConverter.ToString(hashBytes).Replace("-", "").ToLower();

            ChangePasswordUser.ContinueDestinationPageUrl = ConfigurationSettings.AppSettings["RemoteAuthUrl"] + "ChatRoom.aspx?id=" + id + "&timestamp=" + timestamp + "&hash=" + hash;
        }
        protected void ChangePasswordUser_CancelChangedPassword(object sender, EventArgs e)
        {
            string id = User.Identity.Name;
            string secretKey = "abc123";
            string timestamp = DateTime.Now.ToString("yyMMddhhmmss");
            SHA1Managed sha1 = new SHA1Managed();
            byte[] paramBytes = Encoding.UTF8.GetBytes(id + timestamp + secretKey);
            byte[] hashBytes = sha1.ComputeHash(paramBytes);
            string hash = BitConverter.ToString(hashBytes).Replace("-", "").ToLower();

            
            ChangePasswordUser.CancelDestinationPageUrl = ConfigurationSettings.AppSettings["RemoteAuthUrl"] + "ChatRoom.aspx?id="+id+"&timestamp="+timestamp+"&hash="+hash;
        }
        
    }
}